/*
	
	插入数据
	查询
	
*/


var mysql = require('mysql');

var connection = mysql.createConnection({
	host: 'localhost',
	port: 3306,
	database: 'test',
	user: 'root',
	password: '123456'
});


connection.connect(function(err){
	if(err)
		console.log("连接失败");
	else{
		console.log("连接成功");
		connection.query("insert into users set ?", {userName: '李四', passWord: 'ls888'}, function(err, result){
			if(err)
				console.log("插入数据失败");
			else{
				connection.query("select * from ??", ['users'], function(err, result){
					if(err)
						console.log("查询数据失败");
					else{
						console.log(result);
						connection.end();
					}
				});
			}
		});
	}
});